/*
 Given, please output 1/n where (1<=n<=10^5) for the first repetend
Sample Input
3
7
168
Sample Output
0.3
0.142857
0.005952380

Data:2017.04.22
*/



#include <string>
#include <sstream>
#include <iostream>
#include <vector>

using namespace std;

string GetOutput(int n){



    int remain = 1;
    double times = 1;
    stringstream result;
    result <<"0.";

    vector<int> remains;
    remains.push_back(1);

    while(true){

        bool flag = false;


        remain *= 10;
        times *= 10;

        int temp = remain / n;
        result << temp;
        remain = remain % n;


        for(int i=0; i<remains.size(); i++){

            if(remains[i] == remain){
                flag = true;
            }
        }

        if(flag)
            break;


        remains.push_back(remain);

    }


    return result.str();


}


int main(int argc, char *argv[])
{
    string result;

    result = GetOutput(3);
    cout << GetOutput(3) << endl;

    result = GetOutput(7);
    cout << GetOutput(7) << endl;

    double r = 1 / 168.0;
    result =  GetOutput(168);
    cout << GetOutput(168) << endl;


    return 0;
}
